package controller.test;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import service.Article_Management_Service;
import service.DonationService;
import util.ResponseBean;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@Controller
public class Controller3 {


//    @Resource
//    UsersMapper usersMapper;
//
//    @Resource
//    GroudUserMapper groudUserMapper;
//
//    @Resource
//    StoreMapper storeMapper;
//
//    @RequestMapping(value = "/login", method = RequestMethod.POST)
//    @ResponseBody
//    public ResponseBean show(String phone, String password) {
//        ResponseBean responseBean = new ResponseBean();
//
//        Users users=usersMapper.selectByPhone(phone);
//        if(users==null){
//            responseBean.setCode(401);
//            responseBean.setMsg("用户不存在");
//            responseBean.setData(null);
//        }
//        else{
//
//           if(users.getPassword().equals(password)){
//               String Identification=users.getIdentification();
//
//               String groud=groudUserMapper.selectByGroudId(users.getUserId());
//
//               String store=storeMapper.selectByStoreId(users.getUserId());
//
//               String token = JwtUtil.creatToken(Identification,groud,store);
//
//               HashMap<String, Object> hashMap = new HashMap<>();
//               responseBean.setCode(200);
//               responseBean.setMsg("登陆成功");
//               hashMap.put("Token", token);
//               responseBean.setData(hashMap);
//
//           }else{
//               responseBean.setCode(401);
//               responseBean.setMsg("密码有误");
//               responseBean.setData(null);
//           }
//
//        }
//
//
//
//        return responseBean;
//
//    }

    @RequestMapping(value = "/admin2", method = RequestMethod.POST)
    public String show2(String name, HttpServletRequest request) {
//        Session session=SecurityUtils.getSubject().getSession();
//        System.out.println("哈哈"+session.getAttribute("yi"));
        System.out.println("进入了show2(方法 该方法有权限限制");
//        SecurityUtils.getSubject().isPermitted("admin");


        return "user/user";

    }

    @RequestMapping(value = "/admin3", method = RequestMethod.POST)
    @ResponseBody
    public String show3(String name) {

//        SecurityUtils.getSubject().isPermitted("admin");
        return "哈哈";

    }

    @Resource
    private DonationService donationService;

    @Resource
    private Article_Management_Service article_management_service;

    @Resource
    private ResponseBean responseBean;

    @GetMapping("article")
    @ResponseBody
    public ResponseBean all(){
//        List<Public_Welfare_Donation> publicWelfareDonationList = article_management_service.all();
//        responseBean.setAll(200,"all article",publicWelfareDonationList);
//        return responseBean;
        return null;
    }


}
